package bb.lanxing.lib.devices.ble.ble.services;

import android.content.Intent;
//import com.alipay.sdk.packet.d;
import bb.lanxing.lib.base.BaseApplication;
import bb.lanxing.lib.devices.ble.BleCons;
import bb.lanxing.lib.devices.ble.ble.base.BaseBleSensorDevice;
import bb.lanxing.lib.devices.ble.ble.base.BaseBleService;
import bb.lanxing.lib.devices.ble.ble.characteristic.hr.HeartRateAlertCmdCharacteristics;
import bb.lanxing.lib.devices.ble.ble.characteristic.hr.HeartRateAlertNotifyCharacteristics;
import java.util.UUID;
import kotlin.Metadata;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.ContinuationImpl;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.intrinsics.IntrinsicsKt;
import kotlin.jvm.internal.Intrinsics;
/* compiled from: HeartRateAlertService.kt */

public final class HeartRateAlertService extends BaseBleService {
    private HeartRateAlertCmdCharacteristics cmdCharacteristics;

    public HeartRateAlertService(BaseBleSensorDevice device) {
        super(device);
        Intrinsics.checkNotNullParameter(device, "device");
    }

    public HeartRateAlertCmdCharacteristics getCmdCharacteristics() {
        return this.cmdCharacteristics;
    }

    public void setCmdCharacteristics(HeartRateAlertCmdCharacteristics heartRateAlertCmdCharacteristics) {
        this.cmdCharacteristics = heartRateAlertCmdCharacteristics;
    }

    @Override
    public UUID targetUUID() {
        UUID fromString = UUID.fromString("0000fd00-0000-1000-8000-00805f9b34fb");
        Intrinsics.checkNotNullExpressionValue(fromString, "fromString(BLEAttributes…HEART_RATE_ALERT_SERVICE)");
        return fromString;
    }

    public final class HeartRateAlertService$initialization$1 extends ContinuationImpl {
        Object L$0;
        Object L$1;
        int label;
        Object result;
        final HeartRateAlertService this$0;

        public HeartRateAlertService$initialization$1(HeartRateAlertService heartRateAlertService, Continuation<? super HeartRateAlertService$initialization$1> continuation) {
            super((Continuation<Object>) continuation);
            this.this$0 = heartRateAlertService;
        }

        @Override
        public Object invokeSuspend(Object obj) {
            this.result = obj;
            this.label |= Integer.MIN_VALUE;
            return this.this$0.initialization(this);
        }
    }

    @Override
    public Object initialization(Continuation<? super Unit> continuation) {
        HeartRateAlertService$initialization$1 heartRateAlertService$initialization$1;
        Object coroutine_suspended;
        int i;
        HeartRateAlertService heartRateAlertService = null;
        HeartRateAlertService heartRateAlertService2;
        BaseApplication context;
        if (continuation instanceof HeartRateAlertService$initialization$1) {
            heartRateAlertService$initialization$1 = (HeartRateAlertService$initialization$1) continuation;
            if ((heartRateAlertService$initialization$1.label & Integer.MIN_VALUE) != 0) {
                heartRateAlertService$initialization$1.label -= Integer.MIN_VALUE;
                Object obj = heartRateAlertService$initialization$1.result;
                coroutine_suspended = IntrinsicsKt.getCOROUTINE_SUSPENDED();
                i = heartRateAlertService$initialization$1.label;
                if (i != 0) {
                    ResultKt.throwOnFailure(obj);
                    new HeartRateAlertCmdCharacteristics(this);
                    heartRateAlertService$initialization$1.L$0 = this;
                    heartRateAlertService$initialization$1.label = 1;
                    if (delayInPeer(heartRateAlertService$initialization$1) == coroutine_suspended) {
                        return coroutine_suspended;
                    }
                    heartRateAlertService = this;
                } else if (i != 1) {
                    if (i == 2) {
                        HeartRateAlertNotifyCharacteristics heartRateAlertNotifyCharacteristics = (HeartRateAlertNotifyCharacteristics) heartRateAlertService$initialization$1.L$1;
                        heartRateAlertService2 = (HeartRateAlertService) heartRateAlertService$initialization$1.L$0;
                        ResultKt.throwOnFailure(obj);
                        context = heartRateAlertService2.getDevice().getContext();
                        if (context != null) {
                            Intent intent = new Intent(BleCons.ACTION_HERATRATE_ALERT_SUPPORT);
                            intent.putExtra("EXTRA_DEVICE_TYPE", heartRateAlertService2.getDevice().getType());
                            intent.putExtra(BleCons.EXTRA_HR_ALERT_FUTURE, true);
                            intent.putExtra("EXTRA_DEVICE_ADDRESS", heartRateAlertService2.getDevice().getAddress());
                            context.sendBroadcast(intent);
                        }
                        return Unit.INSTANCE;
                    }
                    throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
                } else {
                    heartRateAlertService = (HeartRateAlertService) heartRateAlertService$initialization$1.L$0;
                    ResultKt.throwOnFailure(obj);
                }
                HeartRateAlertNotifyCharacteristics heartRateAlertNotifyCharacteristics2 = new HeartRateAlertNotifyCharacteristics(heartRateAlertService);
                heartRateAlertNotifyCharacteristics2.enableNotify();
                heartRateAlertService$initialization$1.L$0 = heartRateAlertService;
                heartRateAlertService$initialization$1.L$1 = heartRateAlertNotifyCharacteristics2;
                heartRateAlertService$initialization$1.label = 2;
                if (heartRateAlertService.delayInPeer(heartRateAlertService$initialization$1) != coroutine_suspended) {
                    return coroutine_suspended;
                }
                heartRateAlertService2 = heartRateAlertService;
                context = heartRateAlertService2.getDevice().getContext();
                if (context != null) {
                }
                return Unit.INSTANCE;
            }
        }
        heartRateAlertService$initialization$1 = new HeartRateAlertService$initialization$1(this, (Continuation<? super HeartRateAlertService$initialization$1>) continuation);
        Object obj2 = heartRateAlertService$initialization$1.result;
        coroutine_suspended = IntrinsicsKt.getCOROUTINE_SUSPENDED();
        i = heartRateAlertService$initialization$1.label;
        if (i != 0) {
        }
        HeartRateAlertNotifyCharacteristics heartRateAlertNotifyCharacteristics22 = new HeartRateAlertNotifyCharacteristics(heartRateAlertService);
        heartRateAlertNotifyCharacteristics22.enableNotify();
        heartRateAlertService$initialization$1.L$0 = heartRateAlertService;
        heartRateAlertService$initialization$1.L$1 = heartRateAlertNotifyCharacteristics22;
        heartRateAlertService$initialization$1.label = 2;
        if (heartRateAlertService.delayInPeer(heartRateAlertService$initialization$1) != coroutine_suspended) {
        }
        return coroutine_suspended;
    }
}
